<template>
  <view class="page flex-col">
    <view class="section_1 flex-col">
      <view class="group_1 flex-col" style="position: relative;">
        
        <view class="group_3 flex-row justify-center" style="width: 100%;margin-left: 0;">
          <text class="text_4">南通宏熙信息自动化系统</text>
        </view>
        <text class="text_5">欢迎使用</text>
        <image
          class="image_4"
          referrerpolicy="no-referrer"
          src="/static/logo.png"
        />
        <view class="bigbox">
            <view class="inputbox">
                <view class="inputont account">
                    <uni-easyinput 
                    class="easyinput" trim="all"
                      :styles="inputstyle"
                    v-model="account" 
                    focus placeholder="请输入账号" 
                    @input="input"></uni-easyinput>
                    
                </view>
                <view class="inputont password">
                    <uni-easyinput
                    type="password"
                    class="easyinput" trim="all"
                      :styles="inputstyle"
                    v-model="password" 
                    focus placeholder="请输入密码" 
                    @input="input"></uni-easyinput>
                </view>
            </view>    
            <view class="group_5 flex-row justify-between" style="">
              <view class="btn text-wrapper_1 flex-col">
                <text class="txt" @click="kehu()">登录</text>
              </view>
             
            </view>
            <view class="text_8" @click="$navto('/pages/common/richtext?db=set&id=about')">公司简介&gt;&gt;</view>
        </view>
        

    
      </view>
    </view>
    <view class="fixed-check">
      <checkbox-group @change="onChangeChk">
        <label style="display: flex;align-items: center;">
          <view style="transform: scale(0.7); position: relative;top: -2rpx;margin-left: -6rpx;">
            <checkbox value="1" />
          </view>
          <text>我已阅读并同意 <text style="color: #007aff;" @tap="toLink">《隐私政策》</text> </text>
        </label>
      </checkbox-group>
    </view>
  </view>
</template>
<script>
import {setRoles} from "@/common/http.js"
export default {
  data() {
    return {
      constants: {},
      account:'',
      password:'',
      inputstyle:{
          Height:"150rpx"
      },
      cid:"",
      chks: []
    };
  },
  onLoad() {
      var _this = this
    // plus.push.getClientInfoAsync((info) => {
    //      let cid = info["clientid"];
    //      console.log("cid",cid)
    //      _this.cid = cid
    // }); 
  },
  methods: {
    onChangeChk (e) {
      this.chks = e.detail.value;
    },
    toLink () {
      const url = 'http://nantongapi.iceand.cn/arg.html';
      // #ifdef APP
      plus.runtime.openURL(url)
      // #endif
      // #ifdef H5
      location.href = url
      // #endif
    },
      input(){
          
      },
      yaungon(){
          this.tologin('yuangon')
      },
      kehu(){
          this.tologin('kehu')
      },
      tologin(type){
        if (!this.chks.length) {
          return uni.showToast({
            title: '请先阅读并同意《隐私政策》',
            icon: 'none'
          })
        }
          this.$api.post(`login/alllogin`,{
              account:this.account,
              password:this.password,
              cid:this.cid
          }).then((res)=>{
              console.log(res)
                uni.setStorageSync('nangtong_login_token',res.data.token);
                uni.setStorageSync('nantong_role_id',res.data.role_id);
                setRoles(res.data.purview)
                uni.showLoading({
                    
                })
                var _this = this
                setTimeout(function(){
                    uni.hideLoading()
            
                    if(res.data.role_id == 1){
                        uni.redirectTo({
                            url:'/pages/index/index'
                        })
                    }else{
                        uni.switchTab({
                            url:'/pages/index/yuangong'
                        })
                    }
                },500)
               
          }).catch((err)=>{
              console.log(err)
          })
      }
  },
};
</script>
<style lang="less">
page {
  padding: 0;
}
.page {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  .section_1 {
    background-color: rgba(246, 246, 246, 1);
    height: 100vh;
    width: 100vw;
    .group_1 {
      width: 100vw;
      height: 100vh;
      background: url('../../static/login.jpg')
        100% no-repeat;
      background-size: 100% 100%;
      .group_2 {
        width: 720rpx;
        height: 26rpx;
        margin: 7rpx 0 0 15rpx;
        .image_1 {
          width: 67rpx;
          height: 11rpx;
          margin-top: 6rpx;
        }
        .text_1 {
          width: 115rpx;
          height: 26rpx;
          overflow-wrap: break-word;
          color: rgba(0, 0, 0, 1);
          font-size: 24rpx;
          font-family: SourceHanSansCN-Regular;
          font-weight: NaN;
          text-align: left;
          white-space: nowrap;
          line-height: 24rpx;
          margin-left: 8rpx;
        }
        .image_2 {
          width: 25rpx;
          height: 18rpx;
          margin: 2rpx 0 0 5rpx;
        }
        .text_2 {
          width: 95rpx;
          height: 18rpx;
          overflow-wrap: break-word;
          color: rgba(0, 0, 0, 1);
          font-size: 24rpx;
          font-family: SourceHanSansCN-Regular;
          font-weight: NaN;
          text-align: center;
          white-space: nowrap;
          line-height: 24rpx;
          margin: 2rpx 0 0 94rpx;
        }
        .text_3 {
          width: 65rpx;
          height: 19rpx;
          overflow-wrap: break-word;
          color: rgba(0, 0, 0, 1);
          font-size: 24rpx;
          font-family: SourceHanSansCN-Regular;
          font-weight: NaN;
          text-align: right;
          white-space: nowrap;
          line-height: 24rpx;
          margin: 2rpx 0 0 190rpx;
        }
        .image_3 {
          width: 49rpx;
          height: 19rpx;
          margin: 2rpx 0 0 7rpx;
        }
      }
      .group_3 {
        width: 574rpx;
        height: 34rpx;
        margin: 65rpx 0 0 33rpx;
        .group_4 {
          background-color: rgba(255, 255, 255, 1);
          width: 16rpx;
          height: 29rpx;
        }
        .text_4 {
          width: 465rpx;
          height: 34rpx;
          overflow-wrap: break-word;
          color: rgba(255, 255, 255, 1);
          font-size: 36rpx;
          font-family: SourceHanSansCN-Regular;
          font-weight: NaN;
          text-align: left;
          white-space: nowrap;
          line-height: 36rpx;
        }
      }
      .text_5 {
        width: 178rpx;
        height: 43rpx;
        overflow-wrap: break-word;
        color: rgba(255, 255, 255, 1);
        font-size: 46rpx;
        font-family: SourceHanSansCN-Medium;
        font-weight: 500;
        text-align: left;
        white-space: nowrap;
        line-height: 46rpx;
        margin: 143rpx 0 0 281rpx;
      }
      .image_4 {
        width: 109rpx;
        height: 107rpx;
        margin: 67rpx 0 0 315rpx;
      }
      .group_5 {
        width: 636rpx;
        height: 94rpx;
        margin: 38rpx 0 0 92rpx;
        .text-wrapper_1 {
          box-shadow: 0rpx 18rpx 17rpx 0rpx rgba(31, 123, 190, 0.25);
          background-color: rgba(104, 200, 240, 1);
          border-radius: 10rpx;
          height: 93rpx;
          margin-top: 1rpx;
          width: 300rpx;
          .text_6 {
            width: 149rpx;
            height: 36rpx;
            overflow-wrap: break-word;
            color: rgba(255, 255, 255, 1);
            font-size: 31rpx;
            font-family: SourceHanSansCN-Medium;
            font-weight: 500;
            text-align: left;
            white-space: nowrap;
            line-height: 50rpx;
            margin: 32rpx 0 0 74rpx;
          }
        }
        .text-wrapper_2 {
          box-shadow: 0rpx 18rpx 17rpx 0rpx rgba(31, 123, 190, 0.25);
          background-color: rgba(55, 152, 223, 1);
          border-radius: 10rpx;
          height: 93rpx;
          width: 312rpx;
          .text_7 {
            width: 148rpx;
            height: 36rpx;
            overflow-wrap: break-word;
            color: rgba(255, 255, 255, 1);
            font-size: 31rpx;
            font-family: SourceHanSansCN-Medium;
            font-weight: 500;
            text-align: left;
            white-space: nowrap;
            line-height: 183rpx;
            margin: 30rpx 0 0 86rpx;
          }
        }
      }
      .text_8 {
        width: auto;
        height: 31rpx;
        overflow-wrap: break-word;
        color: rgba(55, 152, 223, 1);
        font-size: 27rpx;
        font-family: 郑庆科黄油体Regular;
        font-weight: NaN;
        text-align: left;
        white-space: nowrap;
        line-height: 36rpx;
        margin: 20rpx 0 0 488rpx;
        position: relative;
        z-index: 99;
      }
      .text_9 {
        width: 226rpx;
        height: 36rpx;
        overflow-wrap: break-word;
        color: rgba(55, 152, 223, 1);
        font-size: 30rpx;
        font-family: SourceHanSansCN-Medium;
        font-weight: 500;
        text-align: left;
        white-space: nowrap;
        line-height: 36rpx;
        margin: 10rpx 0 140rpx 252rpx;
      }
    }
  }
}
.group_5 {
    width: 520rpx !important;
    // transform:translate(60rpx,340rpx) ;
    .btn{
        width: 520rpx !important;
        line-height: 92rpx;
        text-align: center;
        .txt{   
            overflow-wrap: break-word;
            color: rgba(255, 255, 255, 1);
            font-size: px;
            font-family: SourceHanSansCN-Medium;
            font-weight: 500;
            text-align: center;
            white-space: nowrap;  
        }
    }
}
.inputbox{
    width: 520rpx ;
    margin: 0 auto;
    margin-top: 120rpx;
    .inputont{
        width: 520rpx;
        height: 90rpx;
        background-color: #fdedd9;
    }
    .password{
        margin-top: 30rpx;
    }
}
.bigbox{
    width: 700rpx;
    height: 550rpx;
    margin: 0 auto;
    border-radius: 20rpx;
    background-color: #fff;
    margin-top: 20rpx;
}
.fixed-check {
  position: fixed;
  bottom: 20rpx;
  left: 0;
  width: 100%;
  z-index: 3;
  text-align: center;
  padding: 20rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
</style>
